//
//  YLAMYOthersCell.swift
//  Your Lover AI
//
//  Created by 阿忠 on 2024/6/22.
//

import Foundation
import UIKit

class YLAMYOthersCell: UITableViewCell {
    
    protocol CellDelegate: class {
        func cell(_ cell: YLAMYOthersCell, toher1: Any)
        func cell(_ cell: YLAMYOthersCell, toher2: Any)
        func cell(_ cell: YLAMYOthersCell, toher3: Any)
        func cell(_ cell: YLAMYOthersCell, toher4: Any)
    }
    
    weak var delegate: CellDelegate?
    
    //背景
    lazy var backVc: UIView = {
        let view = UIView()
        view.backgroundColor = .clear
        view.layer.cornerRadius = 10.0 // 设置圆角半径为10.0
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var blueVc: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex: "7157FF")
        view.layer.cornerRadius = 10.0 // 设置圆角半径为10.0
        view.layer.masksToBounds = true
        return view
    }()
    
    //提示
    lazy var titleLab: UILabel = {
        let lab = UILabel()
        lab.text = "Others"
        lab.textColor = UIColor(hex: "FFFFFF")
        lab.font = UIFont.systemFont(ofSize: 15)
        lab.textAlignment = .left
        lab.numberOfLines = 0
        return lab
    }()
    
    //修改图
    lazy var topImg1: UIImageView = {
        let image = UIImageView(image: UIImage(named: "me_police"))
        return image
    }()
    
    lazy var topImg2: UIImageView = {
        let image = UIImageView(image: UIImage(named: "me_terms"))
        return image
    }()
    
    lazy var topImg3: UIImageView = {
        let image = UIImageView(image: UIImage(named: "me_unsubscribe"))
        return image
    }()
    
    lazy var topImg4: UIImageView = {
        let image = UIImageView(image: UIImage(named: "me_rate"))
        return image
    }()
    
    lazy var topLab1: UILabel = {
        let lab = UILabel()
        lab.text = "Privacy Policy"
        lab.textColor = UIColor(hex: "FFFFFF")
        lab.font = UIFont.systemFont(ofSize: 17)
        lab.textAlignment = .left
        lab.numberOfLines = 0
        return lab
    }()
    
    lazy var topLab2: UILabel = {
        let lab = UILabel()
        lab.text = "Term"
        lab.textColor = UIColor(hex: "FFFFFF")
        lab.font = UIFont.systemFont(ofSize: 17)
        lab.textAlignment = .left
        lab.numberOfLines = 0
        return lab
    }()
    
    lazy var topLab3: UILabel = {
        let lab = UILabel()
        lab.text = "Unsubscribe"
        lab.textColor = UIColor(hex: "FFFFFF")
        lab.font = UIFont.systemFont(ofSize: 17)
        lab.textAlignment = .left
        lab.numberOfLines = 0
        return lab
    }()
    
    lazy var topLab4: UILabel = {
        let lab = UILabel()
        lab.text = "Rate App"
        lab.textColor = UIColor(hex: "FFFFFF")
        lab.font = UIFont.systemFont(ofSize: 17)
        lab.textAlignment = .left
        lab.numberOfLines = 0
        return lab
    }()

    lazy var rightImg1: UIImageView = {
        let image = UIImageView(image: UIImage(named: "icon_right"))
        return image
    }()
    
    lazy var rightImg2: UIImageView = {
        let image = UIImageView(image: UIImage(named: "icon_right"))
        return image
    }()
    
    lazy var rightImg3: UIImageView = {
        let image = UIImageView(image: UIImage(named: "icon_right"))
        return image
    }()
    
    lazy var rightImg4: UIImageView = {
        let image = UIImageView(image: UIImage(named: "icon_right"))
        return image
    }()
    
    lazy var lineVc1: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    lazy var lineVc2: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    lazy var lineVc3: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    lazy var otherBtn1: UIButton = {
        let button = UIButton(type: .custom)
        button.backgroundColor = .clear
        button.addTarget(self, action: #selector(toher1Click), for: .touchUpInside)
        return button
    }()
    
    lazy var otherBtn2: UIButton = {
        let button = UIButton(type: .custom)
        button.backgroundColor = .clear
        button.addTarget(self, action: #selector(toher2Click), for: .touchUpInside)
        return button
    }()
    
    lazy var otherBtn3: UIButton = {
        let button = UIButton(type: .custom)
        button.backgroundColor = .clear
        button.addTarget(self, action: #selector(toher3Click), for: .touchUpInside)
        return button
    }()
    
    lazy var otherBtn4: UIButton = {
        let button = UIButton(type: .custom)
        button.backgroundColor = .clear
        button.addTarget(self, action: #selector(toher4Click), for: .touchUpInside)
        return button
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        contentView.addSubview(backVc)
        backVc.addSubview(titleLab)
        backVc.addSubview(blueVc)
        blueVc.addSubview(topImg1)
        blueVc.addSubview(topImg2)
        blueVc.addSubview(topImg3)
        blueVc.addSubview(topImg4)
        blueVc.addSubview(topLab1)
        blueVc.addSubview(topLab2)
        blueVc.addSubview(topLab3)
        blueVc.addSubview(topLab4)
        blueVc.addSubview(rightImg1)
        blueVc.addSubview(rightImg2)
        blueVc.addSubview(rightImg3)
        blueVc.addSubview(rightImg4)
        blueVc.addSubview(lineVc1)
        blueVc.addSubview(lineVc2)
        blueVc.addSubview(lineVc3)
        blueVc.addSubview(otherBtn1)
        blueVc.addSubview(otherBtn2)
        blueVc.addSubview(otherBtn3)
        blueVc.addSubview(otherBtn4)
       
        initUI()
    }

    
    func initUI()
    {
        backVc.snp.makeConstraints { make in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
        }
        
        titleLab.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.top.equalTo(21)
            make.height.equalTo(15)
        }
        
        blueVc.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.right.equalTo(-16)
            make.top.equalTo(titleLab.snp.bottom).offset(15)
            make.height.equalTo(235)
        }
        
        topImg1.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.top.equalTo(20)
            make.width.height.equalTo(26)
        }
        
        topImg2.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.top.equalTo(topImg1.snp.bottom).offset(30)
            make.width.height.equalTo(26)
        }
        
        topImg3.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.top.equalTo(topImg2.snp.bottom).offset(30)
            make.width.height.equalTo(26)
        }
        
        topImg4.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.top.equalTo(topImg3.snp.bottom).offset(30)
            make.width.height.equalTo(26)
        }
        
        topLab1.snp.makeConstraints { make in
            make.left.equalTo(topImg1.snp.right).offset(10)
            make.centerY.equalTo(topImg1)
        }
        
        topLab2.snp.makeConstraints { make in
            make.left.equalTo(topImg2.snp.right).offset(10)
            make.centerY.equalTo(topImg2)
        }
        
        topLab3.snp.makeConstraints { make in
            make.left.equalTo(topImg3.snp.right).offset(10)
            make.centerY.equalTo(topImg3)
        }
        
        topLab4.snp.makeConstraints { make in
            make.left.equalTo(topImg4.snp.right).offset(10)
            make.centerY.equalTo(topImg4)
        }
        
        rightImg1.snp.makeConstraints { make in
            make.right.equalTo(-20)
            make.centerY.equalTo(topImg1)
            make.width.height.equalTo(29)
        }
        
        rightImg2.snp.makeConstraints { make in
            make.right.equalTo(-20)
            make.centerY.equalTo(topImg2)
            make.width.height.equalTo(29)
        }
        
        rightImg3.snp.makeConstraints { make in
            make.right.equalTo(-20)
            make.centerY.equalTo(topImg3)
            make.width.height.equalTo(29)
        }
        
        rightImg4.snp.makeConstraints { make in
            make.right.equalTo(-20)
            make.centerY.equalTo(topImg4)
            make.width.height.equalTo(29)
        }
        
        lineVc1.snp.makeConstraints { make in
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.top.equalTo(topImg1.snp.bottom).offset(15)
            make.height.equalTo(0.2)
        }
        
        lineVc2.snp.makeConstraints { make in
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.top.equalTo(topImg2.snp.bottom).offset(15)
            make.height.equalTo(0.2)
        }
        
        lineVc3.snp.makeConstraints { make in
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.top.equalTo(topImg3.snp.bottom).offset(15)
            make.height.equalTo(0.2)
        }
        
        otherBtn1.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalToSuperview()
            make.height.equalTo(56)
        }
        
        otherBtn2.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(otherBtn1.snp.bottom)
            make.height.equalTo(56)
        }
        
        otherBtn3.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(otherBtn2.snp.bottom)
            make.height.equalTo(56)
        }
        
        otherBtn4.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(otherBtn3.snp.bottom)
            make.height.equalTo(56)
        }
       
    }
    
    @objc func toher1Click(){
        print("--------toher1Click-----------")
        delegate?.cell(self, toher1: "1")
    }
    
    @objc func toher2Click(){
        print("--------toher1C2ick-----------")
        delegate?.cell(self, toher2: "2")
    }
    
    @objc func toher3Click(){
        print("--------toher3Click-----------")
        delegate?.cell(self, toher3: "3")
    }
    
    @objc func toher4Click(){
        print("--------toher4Click-----------")
        delegate?.cell(self, toher4: "4")
    }
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

